home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 August: Tool Chest / Dev.CD Aug 98 TC.toast / Sample Code / OS Utilities / CPUGestalt / CPUGestalt.c next >
Encoding:
C/C++ Source or Header  |  1997-02-11  |  1.5 KB  |  49 lines  |  [TEXT/CWIE]

  1. //
  2. //     CPUGestalt.c
  3. //
  4. //    This sample code illustrates the way to determine the 
  5. //    processor type of the Macintosh you're running on    
  6. //
  7. //    For the latest Gestalt CPU type, refer to the 
  8. //    latest Gestalt.h
  9. //
  10.  
  11. #include <Gestalt.h>
  12. #include <stdio.h>
  13.  
  14. main()
  15. {
  16.     OSErr    err;
  17.     long    getCPUtype;
  18.         
  19.     // check to see if we're on a Power Macintosh
  20.     err = Gestalt (gestaltNativeCPUtype, &getCPUtype);
  21.     
  22.     if (0x100 & getCPUtype) {
  23.         // we are on a Power Macintosh
  24.         if (getCPUtype == gestaltCPU601)
  25.             printf( "\nThis is a Power Macintosh with a 601 processor." );
  26.         else if (getCPUtype == gestaltCPU603)
  27.             printf( "\nThis is a Power Macintosh with a 603 processor." );
  28.         else if (getCPUtype == gestaltCPU604)
  29.             printf( "\nThis is a Power Macintosh with a 604 processor." );
  30.         else
  31.             printf( "\nThis is a Power Macintosh with a processor that I am unaware of." );
  32.     } else {
  33.         // we are on a 68K Macintosh
  34.         err = Gestalt ( gestaltProcessorType, &getCPUtype );
  35.         if (getCPUtype == gestalt68040)
  36.             printf( "\nThis is a 68K Macintosh with a 68040 processor." );
  37.         else if (getCPUtype == gestalt68030)
  38.             printf( "\nThis is a 68K Macintosh with a 68030 processor." );
  39.         else if (getCPUtype == gestalt68020)
  40.             printf( "\nThis is a 68K Macintosh with a 68020 processor." );
  41.         else if (getCPUtype == gestalt68010)
  42.             printf( "\nThis is a 68K Macintosh with a 68010 processor." );
  43.         else if (getCPUtype == gestalt68000)
  44.             printf( "\nThis is a 68K Macintosh with a 68000 processor." );
  45.         else
  46.             printf( "\nThis is a 68K Macintosh with a processor that I am unaware of." );
  47.     }
  48. }
  49.